SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
2.1 KB · 31 lines tsx
Raw Blame History
1import { ImageResponse } from 'next/og';2import { Fallback, Wallpaper } from '@/components/brand/og';3import { api, apiD1, safe } from '@/lib/api';4import { fmtInt, num } from '@/lib/format';5import { SITE_NAME, typeLabel } from '@/lib/site';67export const runtime = 'nodejs';8export const alt = `Organization on ${SITE_NAME}`;9export const size = { width: 1200, height: 630 };10export const contentType = 'image/png';1112/** Per-organization Open Graph image: wallpaper with the live footprint counters (models · families · papers · announcements). */13export default async function CompanyOgImage({ params }: { params: Promise<{ slug: string }> }) {14  const { slug } = await params;15  const d = await safe(api.entityOfType('companies', slug));16  if (!d) return new ImageResponse(<Fallback label="Organization" />, { ...size });17  const [models, fams, papers] = await Promise.all([safe(api.models({ org: d.slug, limit: 1 })), safe(apiD1.families({ org: d.slug, limit: 1 })), safe(api.papers({ org: d.slug, limit: 1 }))]);18  const a = d.attributes ?? {};19  const counters: [string, string][] = [];20  const m = num(models?.total) ?? num(d.model_count) ?? num(d.models?.total);21  if (m !== null) counters.push(['Models', fmtInt(m)]);22  const f = num(fams?.total);23  if (f !== null && f > 0) counters.push(['Families', fmtInt(f)]);24  const p = num(papers?.total) ?? num(d.paper_count);25  if (p !== null && p > 0) counters.push(['Papers', fmtInt(p)]);26  if (typeof a.country === 'string') counters.push(['Country', a.country]);27  if (a.founded) counters.push(['Founded', String(a.founded).slice(0, 4)]);28  const eyebrow = typeof a.org_kind === 'string' && a.org_kind.toLowerCase() !== typeLabel(d.entity_type).toLowerCase() ? `${typeLabel(d.entity_type)} · ${a.org_kind}` : typeLabel(d.entity_type);29  return new ImageResponse(<Wallpaper eyebrow={eyebrow} title={d.name} subtitle={d.description ? d.description.slice(0, 140) : 'Models, families, research, providers, corporate news and sources.'} counters={counters.slice(0, 5)} footer={`www.ai-atlas.co/companies/${d.slug}`} markPx={200} />, { ...size });30}31